<template>
<view class="container">
    <view class="headerBar">以下{{store_list.length}}店通用</view>
    <view class="storeBox bw mt20">
        <block v-for="(item, index) in store_list" :key="index">
            <view class="item" @tap="openMap" :data-lat="item.lat" :data-lng="item.lng" data-type="baidu" :data-name="item.name" :data-address="item.area_name + '' + item.adress">
                <view class="name">{{item.name}}</view>
                <view class="address">{{item.area_name}}{{item.adress}}</view>
                <view class="phone" @click.stop="callPhone" :data-phone="item.phone"></view>
            </view>
        </block>
    </view>
</view>
</template>

"<script>
import common from '../../utils/common.js'
var app = getApp();
var _this;

export default {
  data() {
    return {
      store_list: []
    };
  },

  onUnload: function () {},
  onHide: function () {},
  onShow: function () {},
  onReady: function () {},
  onLoad: function (options) {
    _this = this;
    common.setMainColor(_this);
    var store_list = wx.getStorageSync('group_store_list');

    if (!store_list || store_list.length == 0) {
      wx.navigateBack();
    } else {
      this.setData({
        store_list: store_list
      });
    }

    wx.removeStorage({
      key: 'group_store_list'
    });
    console.log(store_list);
  },
  components: {},
  props: {},
  methods: {
    callPhone: function (e) {
      common.callPhone(e.currentTarget.dataset.phone);
    },
    openMap: function (e) {
      common.openMap(e.currentTarget.dataset);
    },
    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style>
.headerBar {
    height: 92rpx;
    line-height: 92rpx;
    margin-bottom: 12rpx;
    background-color: white;
    color: #999;
    width: 100%;
    padding-left:24rpx;
}


.storeBox .item{
    border-bottom:2rpx solid #f1f1f1;
    padding: 24rpx 128rpx 16rpx 24rpx;
    position: relative;
}
.storeBox .item:last-child {
    border-bottom: none;
}
.storeBox .item .name {
    color: black;
    font-size: 32rpx;
    line-height: 2;
}
.storeBox .item .address {
    color: #999;
    line-height: 2;
    text-overflow: ellipsis;
    overflow: hidden;
    height: 56rpx;
    font-size:24rpx;
}
.storeBox .item .phone {
    position: absolute;
    right: 0px;
    width: 124rpx;
    border-left:2rpx solid #f1f1f1;
    top: 30rpx;
    bottom: 30rpx;
    background: url(https://hf.pigcms.com/tpl/Wap/pure/static/img/phoneBig.png) no-repeat;
    background-size: 36rpx;
    background-position: center center;
}
</style>